import "@site/src/languages/highlight";

# Keyboard

**描述：**

&emsp;&emsp;用于处理键盘事件的接口类。

## Keyboard.KeyName

**类型：** 枚举。

**描述：**

&emsp;&emsp;键盘按键名称的枚举。

**签名：**
```tl
enum KeyName
	"Return"
	"Escape"
	"BackSpace"
	"Tab"
	"Space"
	"!"
	"\""
	"#"
	"%"
	"$"
	"&"
	"'"
	"("
	")"
	"*"
	"+"
	","
	"-"
	"."
	"/"
	"1"
	"2"
	"3"
	"4"
	"5"
	"6"
	"7"
	"8"
	"9"
	"0"
	":"
	";"
	"<"
	"="
	">"
	"?"
	"@"
	"["
	"\\"
	"]"
	"^"
	"_"
	"`"
	"A"
	"B"
	"C"
	"D"
	"E"
	"F"
	"G"
	"H"
	"I"
	"J"
	"K"
	"L"
	"M"
	"N"
	"O"
	"P"
	"Q"
	"R"
	"S"
	"T"
	"U"
	"V"
	"W"
	"X"
	"Y"
	"Z"
	"Delete"
	"CapsLock"
	"F1"
	"F2"
	"F3"
	"F4"
	"F5"
	"F6"
	"F7"
	"F8"
	"F9"
	"F10"
	"F11"
	"F12"
	"PrintScreen"
	"ScrollLock"
	"Pause"
	"Insert"
	"Home"
	"PageUp"
	"Delete"
	"End"
	"PageDown"
	"Right"
	"Left"
	"Down"
	"Up"
	"Application"
	"LCtrl"
	"LShift"
	"LAlt"
	"LGui"
	"RCtrl"
	"RShift"
	"RAlt"
	"RGui"
end
```

## isKeyDown

**类型：** 函数。

**描述：**

&emsp;&emsp;检查当前帧中是否按下了某个键。

**签名：**
```tl
isKeyDown: function(self: Keyboard, name: KeyName): boolean
```

**参数：**

| 参数名 | 类型 | 描述 |
| --- | --- | --- |
| name | KeyName | 要检查的键的名称。 |

**返回值：**

| 返回类型 | 描述 |
| --- | --- |
| boolean | 按键是否按下。 |

## isKeyUp

**类型：** 函数。

**描述：**

&emsp;&emsp;检查当前帧中是否释放了某个键。

**签名：**
```tl
isKeyUp: function(self: Keyboard, name: KeyName): boolean
```

**参数：**

| 参数名 | 类型 | 描述 |
| --- | --- | --- |
| name | KeyName | 要检查的键的名称。 |

**返回值：**

| 返回类型 | 描述 |
| --- | --- |
| boolean | 按键是否已释放。 |

## isKeyPressed

**类型：** 函数。

**描述：**

&emsp;&emsp;检查某个键是否处于按下状态。

**签名：**
```tl
isKeyPressed: function(self: Keyboard, name: KeyName): boolean
```

**参数：**

| 参数名 | 类型 | 描述 |
| --- | --- | --- |
| name | KeyName | 要检查的键的名称。 |

**返回值：**

| 返回类型 | 描述 |
| --- | --- |
| boolean | 按键是否处于按下状态。 |

## updateIMEPosHint

**类型：** 函数。

**描述：**

&emsp;&emsp;更新系统输入法（IME）弹出的位置提示。

**签名：**
```tl
updateIMEPosHint: function(self: Keyboard, winPos: Vec2)
```

**参数：**

| 参数名 | 类型 | 描述 |
| --- | --- | --- |
| winPos | Vec2 | 弹出输入法窗口的位置。 |